package cn.pengyinrui.pethome.dept.service.impl;

import cn.pengyinrui.pethome.dept.domain.Department;
import cn.pengyinrui.pethome.dept.mapper.DepartmentMapper;
import cn.pengyinrui.pethome.dept.query.DepartmentQuery;
import cn.pengyinrui.pethome.dept.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DepartmentServiceImpl implements IDepartmentService {

    @Autowired
    private DepartmentMapper mapper;
    @Override
    public Department findOne(Long id) {
        return mapper.findOne(id);
    }

    @Override
    public List<Department> findAll() {
        return mapper.findAll();
    }

    @Override
    public List<Department> findAllByQuery(DepartmentQuery query) {
        return mapper.findAllByQuery(query);
    }

    @Override
    public Long findAllByQueryCount(DepartmentQuery query) {
        return mapper.findAllByQueryCount(query);
    }

    @Override
    @Transactional
    public void add(Department department) {
        mapper.add(department);
    }

    @Override
    @Transactional
    public void update(Department department) {
        mapper.update(department);
    }

    @Override
    @Transactional
    public void delete(long id) {
        mapper.delete(id);
    }
}
